home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c / 271 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  2.2 KB

  1. Path: newshost.lanl.gov!tanmoy
  2. From: tanmoy@qcd.lanl.gov (Tanmoy Bhattacharya)
  3. Newsgroups: comp.std.c
  4. Subject: Re: Are macros expanded within unused macro arguments?
  5. Date: 01 Feb 1996 17:20:25 GMT
  6. Organization: Los Alamos National Laboratory
  7. Message-ID: <TANMOY.96Feb1102025@qcd.lanl.gov>
  8. References: <DM3MC3.Atv@scr.siemens.com>
  9. NNTP-Posting-Host: qcd.lanl.gov
  10. Mime-Version: 1.0
  11. Content-Type: text
  12. In-reply-to: mlg@scr.siemens.com's message of Thu, 1 Feb 1996 13:19:14 GMT
  13.  
  14. In article <DM3MC3.Atv@scr.siemens.com> mlg@scr.siemens.com (Michael
  15. Greenberg) writes: 
  16. <snip>
  17.    Is the following program legal?
  18.  
  19.    #define foo(unused)
  20.    #define bar(x,y)
  21.  
  22.    foo(bar(1))
  23.  
  24. I read it as being legal.
  25.  
  26.    Excerpt from "6.8.3.1 Argument substitution"
  27.  
  28.      After the arguments for the invocation of a function-like macro have
  29.      been identified, argument substitution takes place. A parameter in the
  30.      replacment list, ..., is replaced by the corresponding argument after
  31.      all macros contained therein have been expanded. Before being
  32.      substituted, each argument's preprocessing tokens are completely macro
  33.      replaced ... .
  34.  
  35. You gave the reason :-) The quoted text seems to imply the following
  36. order:
  37.   1) Identify parameters
  38.   2) parameters in the replacement list identified
  39.   3) expansion of the above parameters (if not preceded by # or ## or
  40.      followed by ##)
  41.   4) substitution
  42.  
  43. There is a different problem in the quoted text though: it says that
  44. before substitution, all macros contained in the parameter are
  45. supposed to be expanded. I do not think that is what is meant though:
  46. function like macros not followed by ( cannot be expanded according to
  47. the last sentence: and I guess this is what was meant anyway.
  48.  
  49. Cheers
  50. Tanmoy
  51. --
  52. tanmoy@qcd.lanl.gov(128.165.23.46) DECNET: BETA::"tanmoy@lanl.gov"(1.218=1242)
  53. Tanmoy Bhattacharya O:T-8(MS B285)LANL,NM87545 H:#9,3000,Trinity Drive,NM87544
  54. Others see <gopher://yaleinfo.yale.edu:7700/00/Internet-People/internet-mail>,
  55. <http://alpha.acast.nova.edu/cgi-bin/inmgq.pl>or<ftp://csd4.csd.uwm.edu/pub/
  56. internetwork-mail-guide>. -- <http://nqcd.lanl.gov/people/tanmoy/tanmoy.html>
  57. fax: 1 (505) 665 3003   voice: 1 (505) 665 4733    [ Home: 1 (505) 662 5596 ]
  58.